#include <iostream>
#include <algorithm>

long long n, x, y, c;

long long calc(long long x, long long y, long long mid)
{
	if (mid >= x + y - 2) return x * y;
	if (x > y) std::swap(x, y);
	if (mid < x) return (1 + mid + 1) * (mid + 1) / 2;
	if (mid < y) {
		long long ret = (1 + x) * x / 2;
		ret += (mid + 1 - x) * x;
		return ret;
	}
	long long t = x - 1 - (mid + 1 - y);
	return x * y - (1 + t) * t / 2;
}

bool judge(long long mid)
{
	long long count = 1;
	count += calc(x, y, mid);
	count += calc(x, n - y + 1, mid);
	count += calc(n - x + 1, y, mid);
	count += calc(n - x + 1, n - y + 1, mid);
	count -= std::min(mid + 1, x);
	count -= std::min(mid + 1, y);
	count -= std::min(mid + 1, n - x + 1);
	count -= std::min(mid + 1, n - y + 1);
	return count >= c;
}

int main()
{
	std::ios_base::sync_with_stdio(false);
	std::cin >> n >> x >> y >> c;
	long long l = 0, r = 4 * n;
	//std::cerr << judge(0) << "\n"; return 0;
	while (l + 1 < r) {
		long long mid = (l + r) / 2;
		if (judge(mid)) r = mid;
		else l = mid;
	}
	if (judge(l)) r = l;
	std::cout << r << "\n";
}

